-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Add missing decorators: @versioning_class()
, @content_negotiation_class()
, @metadata_class()
#9719
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good
Yes, I think that if you add one, it makes sense to add all 3 that you found were missing 👍🏻 |
@versioning_class()
@versioning_class()
, @content_negotiation_class()
, @metadata_class()
Sure @browniebroke, I've amended this PR to add all of them. Do the tests for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may be we have to update the relevant docs for these, as well?
@@ -186,6 +186,9 @@ The available decorators are: | |||
* `@authentication_classes(...)` | |||
* `@throttle_classes(...)` | |||
* `@permission_classes(...)` | |||
* `@content_negotiation_class(...)` | |||
* `@metadata_class(...)` | |||
* `@versioning_class(...)` | |||
|
|||
Each of these decorators takes a single argument which must be a list or tuple of classes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That statement needs to be updated, the ones we're adding are accepting a single class, not a list or tuple of classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. My guess is the original wording is meant to clarify that they should be used like
@api_view(["GET"])
@renderer_classes([RenderA, RenderB])
def view(request):
pass
rather than
@api_view(["GET"])
@render_classes(RenderA, RenderB)
def view(request):
pass
How about something like:
Each of these decorators is equivalent to setting their respective api policy attributes.
Decorators that end withclasses
take a single argument which must be a list or tuple of classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good start, I would go one step further and explicitly outline what each form expect. Something along the lines of:
Each of these decorators is equivalent to setting their respective api policy attributes.
All decorators take a single argument. The ones that end with_class
expect a single class while the ones ending in_classes
expect a list or tuple of classes.
This adds the three missing decorators, fixing #9716.
@content_negotiation_class()
@metadata_class()
@versioning_class()